#pragma once
#include "TouchDefine.h"

enum EObjectType
{
	NONE = 0,
	RECTANGLE,
	CIRCLE,
	PLANE,
};

enum ECollideEdge
{
	NOCOLLIDE = 0,
	LEFT = 1 << 0,
	TOP = 1 << 1,
	RIGHT = 1 << 2,
	BOTTOM = 1 << 3,
	
};

class Object
{
public:
	Object(void);
	Object(float posX, float posY);
	virtual ~Object(void);

	virtual void Render() = 0;
	virtual void Update(float frameTime);

	virtual bool IsInRect(int x, int y) = 0;
	virtual void HandleTouchAction(Touch *touch) = 0;

	void SetPosition(float x, float y);
	void SetVelocityDefault(float vel);
	float GetVelocityDefault();
	
	void SetMass(int);
	void MoveBy(float addX, float addY);
	void SetType(EObjectType type);
	EObjectType GetType();

	void SetAcceleration(float accX, float accY);
	void AddForce(float forceX, float forceY);
	void AddAcceleration(float accX, float accY);
	void AddVelo(float velX, float velY);
	void SetVelocity(float velX, float velY);
	int GetMass();

	float GetPosX();
	float GetPosY();

	void SetDestPos(float posX, float posY);

	virtual float GetCenterPosX();
	virtual float GetCenterPosY();

	virtual bool IsCollideWithObject(Object* object);
	virtual int IsCollideEdge();

	bool CheckFlag(int flag, int mask);

	void SetSelect(bool select);
	bool IsSelected();

	static const float k_Gravity;

protected:
	float m_iPositionX, m_iPositionY;
	float m_iDestPosX, m_iDestPosY;
	
	int m_iMass;
	float m_iVelocity;
	float m_fVeloX, m_fVeloY;

	EObjectType m_Type;
	float m_fAccelerationX, m_fAccelerationY;

	bool m_isSelected;

	static const int k_DefaultMass = 10;
	
	static const float k_PixelPerMeter;
	static const float k_FrictionPercent;
	static const float k_MinVelocity; //reset velocity when reach min
};